#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle("五子棋");
    setWindowFlags(windowFlags() &~(Qt::WindowMaximizeButtonHint));
    setMinimumSize(730, 500);

    view = new GameView(this);
    QHBoxLayout *layout = new QHBoxLayout;

    layout->addWidget(view);
    ui->gameAera->setLayout(layout);
    connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startGame()));
    connect(ui->restartButton, SIGNAL(clicked()), this, SLOT(restartGame()));
    connect(ui->exitButton, SIGNAL(clicked()), this, SLOT(close()));

    ui->warmingLabel->setText("<center style='lineheight:50px'><b>游戏提示：</b><br/><br/>按左右上下方向键移动棋子<br/><br/>\
                              按空格键确定落棋子<br/><br/>禁止在棋盘外按空格<br/><br/>或使用鼠标单击右键落棋</center>");

}

MainWindow::~MainWindow()
{
    delete ui;
}

//开始游戏
void MainWindow::startGame()
{
    view->setFocus();
    view->setPlaying(true);
}

//重新开始游戏
void MainWindow::restartGame()
{
    view->reInit();
    startGame();
}
